home *** CD-ROM | disk | FTP | other *** search
- /*
- File: VirtualRamOrDiskFile.h
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __VIRTUALRAMORDISKFILE__
- #define __VIRTUALRAMORDISKFILE__
-
- #ifndef __VIRTUALFILE__
- #include "VirtualFile.h"
- #endif
-
- #ifndef __IOSTREAM__
- #include <iostream.h>
- #endif
-
- #pragma push
- #pragma segment VirtualFile
-
- /***********************************|****************************************/
-
- class TVirtualRamOrDiskFile : public TVirtualFile
- {
- public:
-
- enum Location { kMemory, kDisk };
-
- TVirtualRamOrDiskFile ( Location = kMemory );
- TVirtualRamOrDiskFile ( Location l, unsigned long ramToDiskThreshold );
- virtual ~TVirtualRamOrDiskFile();
-
- virtual Location GetLocation () const;
- virtual OSErr ForceToDisk();
- virtual OSErr ForceToMemory();
-
- virtual unsigned long GetMaxMemSize() const;
- virtual OSErr SetMaxMemSize(unsigned long maxSize);
-
- virtual OSErr ReadData (void* buffer,long& count);
- virtual OSErr WriteData (const void* buffer, long& count);
-
- virtual OSErr SetEnd (long logEof);
- virtual OSErr GetEnd (long& logEof) const;
-
- virtual OSErr SetPosition (short posMode, long posOff);
- virtual OSErr GetPosition (long& filePos) const;
-
- static void SetDefaultStorageLocation ( const FSSpec& );
- static void GetDefaultStorageLocation ( FSSpec& );
-
- static unsigned long GetVirtualRamOrDiskFilesCount();
- static unsigned long GetVirtualRamOrDiskFilesSize();
- static void ForceFreeMemory (unsigned long freespace );
-
-
-
- virtual ostream& operator >> ( ostream& ) const;
-
- private: TVirtualRamOrDiskFile ( const TVirtualRamOrDiskFile& );
- TVirtualRamOrDiskFile& operator = ( const TVirtualRamOrDiskFile& );
-
- virtual OSErr ForceTo ( Location, TAbstractFile* );
- virtual TAbstractFile* CreateDiskFile ();
-
- static void UniqueFileName( StringPtr );
- static FSSpec gDefaultStorageLocation;
-
- TAbstractFile* fFile;
- Location fLocation;
- unsigned long fRamLimit;
- long fLength;
- };
-
- /***********************************|****************************************/
-
- inline TVirtualRamOrDiskFile::Location TVirtualRamOrDiskFile::GetLocation () const { return fLocation; }
- inline unsigned long TVirtualRamOrDiskFile::GetMaxMemSize() const { return fRamLimit; }
- inline void TVirtualRamOrDiskFile::SetDefaultStorageLocation ( const FSSpec& location ) { gDefaultStorageLocation = location; }
- inline void TVirtualRamOrDiskFile::GetDefaultStorageLocation ( FSSpec& location ) { location = gDefaultStorageLocation; }
-
- /***********************************|****************************************/
-
- #pragma pop
-
- #endif // __VIRTUALRAMORDISKFILE__
-